{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "bd1a081f3f7f5752",
   "metadata": {},
   "outputs": [],
   "source": [
    "## Uninstall"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1175f3d6c5ee9bf0",
   "metadata": {},
   "source": [
    "### Uninstall the Operator and Feast Instance"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "f4b4c6fa4a1fe0a8",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-03-14T14:45:22.053112Z",
     "start_time": "2025-03-14T14:45:15.816729Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "featurestore.feast.dev \"sample-kubernetes-auth\" deleted\n",
      "namespace \"feast-operator-system\" deleted\n",
      "customresourcedefinition.apiextensions.k8s.io \"featurestores.feast.dev\" deleted\n",
      "serviceaccount \"feast-operator-controller-manager\" deleted\n",
      "role.rbac.authorization.k8s.io \"feast-operator-leader-election-role\" deleted\n",
      "clusterrole.rbac.authorization.k8s.io \"feast-operator-featurestore-editor-role\" deleted\n",
      "clusterrole.rbac.authorization.k8s.io \"feast-operator-featurestore-viewer-role\" deleted\n",
      "clusterrole.rbac.authorization.k8s.io \"feast-operator-manager-role\" deleted\n",
      "clusterrole.rbac.authorization.k8s.io \"feast-operator-metrics-auth-role\" deleted\n",
      "clusterrole.rbac.authorization.k8s.io \"feast-operator-metrics-reader\" deleted\n",
      "rolebinding.rbac.authorization.k8s.io \"feast-operator-leader-election-rolebinding\" deleted\n",
      "clusterrolebinding.rbac.authorization.k8s.io \"feast-operator-manager-rolebinding\" deleted\n",
      "clusterrolebinding.rbac.authorization.k8s.io \"feast-operator-metrics-auth-rolebinding\" deleted\n",
      "service \"feast-operator-controller-manager-metrics-service\" deleted\n",
      "deployment.apps \"feast-operator-controller-manager\" deleted\n"
     ]
    }
   ],
   "source": [
    "!kubectl delete -f ../../infra/feast-operator/config/samples/v1alpha1_featurestore_kubernetes_auth.yaml\n",
    "!kubectl delete -f ../../infra/feast-operator/dist/install.yaml"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2a2aa884aeddfb99",
   "metadata": {},
   "source": [
    "## Delete RoleBindings and ServiceAccounts\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "6ce30879d64bbd06",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-03-14T14:45:47.419179Z",
     "start_time": "2025-03-14T14:45:46.325817Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Deleting RoleBindings...\n",
      "rolebinding.rbac.authorization.k8s.io \"feast-user-rolebinding\" deleted\n",
      "rolebinding.rbac.authorization.k8s.io \"feast-admin-rolebinding\" deleted\n",
      "Deleting ServiceAccounts...\n",
      "serviceaccount \"feast-user-sa\" deleted\n",
      "serviceaccount \"feast-admin-sa\" deleted\n",
      "serviceaccount \"feast-unauthorized-user-sa\" deleted\n"
     ]
    }
   ],
   "source": [
    "!echo \"Deleting RoleBindings...\"\n",
    "!kubectl delete rolebinding feast-user-rolebinding -n feast --ignore-not-found\n",
    "!kubectl delete rolebinding feast-admin-rolebinding -n feast --ignore-not-found\n",
    "\n",
    "!echo \"Deleting ServiceAccounts...\"\n",
    "!kubectl delete serviceaccount feast-user-sa -n feast --ignore-not-found\n",
    "!kubectl delete serviceaccount feast-admin-sa -n feast --ignore-not-found\n",
    "!kubectl delete serviceaccount feast-unauthorized-user-sa -n feast --ignore-not-found\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "fa7a79763774f770",
   "metadata": {},
   "source": [
    "### Delete Client Example Deployments"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "7bc23b3eb0153c75",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-03-14T14:46:05.998191Z",
     "start_time": "2025-03-14T14:46:05.344334Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "deployment.apps \"client-admin-user\" deleted\n",
      "deployment.apps \"client-readonly-user\" deleted\n",
      "deployment.apps \"client-unauthorized-user\" deleted\n",
      "configmap \"client-feature-repo-config\" deleted\n"
     ]
    }
   ],
   "source": [
    "!kubectl delete -f client/admin_user_deployment.yaml\n",
    "!kubectl delete -f client/readonly_user_deployment.yaml\n",
    "!kubectl delete -f client/unauthorized_user_deployment.yaml\n",
    "!kubectl delete configmap client-feature-repo-config -n feast"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ce8ef7c832d146dd",
   "metadata": {},
   "source": [
    "### Validate all Objects Removed from Namespace and Delete the Namespace"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "587eb85352a8a353",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-03-14T14:46:14.626703Z",
     "start_time": "2025-03-14T14:46:14.429984Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "NAME                                            READY   STATUS        RESTARTS   AGE\n",
      "pod/client-admin-user-6766944d96-qnd7t          1/1     Terminating   0          18m\n",
      "pod/client-readonly-user-7c6bf454f6-ccj2z       1/1     Terminating   0          29m\n",
      "pod/client-unauthorized-user-698f87f849-zv9cg   1/1     Terminating   0          25m\n"
     ]
    }
   ],
   "source": [
    "!kubectl get all -n feast"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "7a0ce2d9e4a92828",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-03-14T14:46:26.127988Z",
     "start_time": "2025-03-14T14:46:20.865605Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "namespace \"feast\" deleted\n"
     ]
    }
   ],
   "source": [
    "!kubectl delete namespace feast"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": ".venv",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.11"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
